import 'dart:convert';

import 'package:app_30/json/gogngao_entity_helper.dart';
import 'package:app_30/json/load_entity_helper.dart';
import 'package:app_30/json/vip_entity_helper.dart';
import 'package:app_30/models/gogngao_entity.dart';
import 'package:app_30/models/load_entity.dart';
import 'package:app_30/models/vip_entity.dart';
import 'package:app_30/util/sp_util.dart';

setIdentifier(String entity) {
  SpUtil.putString("identifier", entity);
}

String? getIdentifier() {
  return SpUtil.getString("identifier") as String;
}

setPlatform(String entity) {
  SpUtil.putString("platform", entity);
}

String? getPlatform() {
  return SpUtil.getString("platform") as String;
}
setDevise(String entity) {
  SpUtil.putString("Devise", entity);
}

String? getDevise() {
  return SpUtil.getString("Devise") as String;
}

setLoadData(LoadEntity entity) {
  SpUtil.putString("loadData", json.encode(loadEntityToJson(entity)));
}

LoadEntity? getLoadData() {
  String value = SpUtil.getString("loadData") as String;
  if (SpUtil.getObject("loadData") == null) {
    return null;
  } else {
    return loadEntityFromJson(LoadEntity(), json.decode(value));
  }
}

setUser(String entity) {
  SpUtil.putString("user", entity);
}

String? getUser() {
  return SpUtil.getString("user") as String;
}

setPwd(String entity) {
  SpUtil.putString("password", entity);
}

String? getPwd() {
  return SpUtil.getString("password") as String;
}

setRegcode(String entity) {
  SpUtil.putString("regcode", entity);
}

String? getRegcode() {
  return SpUtil.getString("regcode") as String;
}

setVipData(VipEntity entity) {
  SpUtil.putString("vipdata", json.encode(vipEntityToJson(entity)));
}

VipEntity? getVipData() {
  String value = SpUtil.getString("vipdata") as String;
  if (SpUtil.getObject("vipdata") == null) {
    return VipEntity();
  } else {
    return vipEntityFromJson(VipEntity(), json.decode(value));
  }
}

setGonggao(GonggaoEntity entity) {
  SpUtil.putString("gonggao", json.encode(gonggaoEntityToJson(entity)));
}

GonggaoEntity? getGonggao() {
  String value = SpUtil.getString("gonggao") as String;
  if (SpUtil.getObject("gonggao") == null) {
    return GonggaoEntity();
  } else {
    return gonggaoEntityFromJson(GonggaoEntity(), json.decode(value));
  }
}

setmoney(String entity) {
  SpUtil.putString("money", entity);
}

String? getmoney() {
  return SpUtil.getString("money") as String;
}

setTgUrl(String entity) {
  SpUtil.putString("tgurl", entity);
}

String? getTgUrl() {
  return SpUtil.getString("tgurl") as String;
}
